const multer = require('multer');
const { extname } = require('path')

// 设置存储配置
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, 'public/uploads/') // 文件存储路径
  },
  filename: function (req, file, cb) {
    const fileNanme = `${new Date().getTime() + extname(file.originalname)}`
    cb(null, fileNanme)
  }
})

const upload = multer({ storage: storage });

exports.upload = upload;